import {
  SystemEventApi,
  SystemZeroCodeAutomationRun,
  SystemZeroCodeFindById,
  SystemZeroCodeQuery,
  SystemWorkSheetQuery,
  SystemWorkSheetCorrelationRows,
  SystemWorkSheetFooter,
  SystemWorkSheetDelete,
  SystemWorkSheetDeletePhysics,
  SystemWorkSheetDeletePhysicsAll,
  SystemWorkSheetDeleteRecovery,
  SystemWorkSheetQueryFilterSearch,
  SystemWorkSheetReport,
  SystemZeroCodeDataReportTemplate,
  SystemZeroCodeDataImport,
  SystemZeroCodeDataImportTable,
  SystemZeroCodeDataImportTemplate,
  WorkflowEngineRevokeByCreateUser,
  SystemZeroCodeDataFindFormSourcePagingTable,
  SystemUserMenuZeroCode,
  SystemWorkSheetFindById,
  SystemWorkSheetCopy,
  SystemZeroCodeGridCustomSave,
  SystemZeroCodeGridCustomFindByKey,
} from "@/services/api";
import { request, requestSync, excelDownload, METHOD } from "@/utils/request";
/**
 * 根据Id获取业务数据
 */
export function findById(param) {
  return request(SystemWorkSheetFindById, METHOD.POST, param);
}

/**
 * 查询业务数据
 */
export async function queryConfig(param) {
  return request(SystemZeroCodeQuery, METHOD.POST, param);
}

/**
 * 查询业务数据
 */
export async function query(param) {
  return request(SystemWorkSheetQuery, METHOD.POST, param);
}
/**
 * 查询业务数据
 */
export async function queryFilterSearch(param) {
  return request(SystemWorkSheetQueryFilterSearch, METHOD.POST, param);
}

/**
 * 查询业务数据
 */
export async function queryCorrelation(param) {
  return request(SystemWorkSheetCorrelationRows, METHOD.POST, param);
}
/**
 * 获取表尾数据
 */
export function queryFooter(param) {
  return request(SystemWorkSheetFooter, METHOD.POST, param);
}
/**
 * 删除业务数据
 */
export async function del(param) {
  return request(SystemWorkSheetDelete, METHOD.POST, param);
}
/**
 * 删除业务数据
 */
export async function delPhysics(param) {
  return request(SystemWorkSheetDeletePhysics, METHOD.POST, param);
}
/**
 * 删除业务数据
 */
export async function delPhysicsAll(param) {
  return request(SystemWorkSheetDeletePhysicsAll, METHOD.POST, param);
}
/**
 * 删除业务数据
 */
export async function delRecovery(param) {
  return request(SystemWorkSheetDeleteRecovery, METHOD.POST, param);
}
/**
 * 调用api
 */
export function eventApi(param) {
  return requestSync(SystemEventApi, METHOD.POST, param, {
    timeout: 9999999999999,
  });
}

/**
 * 调用自动化运行
 */
export function automationRun(param) {
  return requestSync(SystemZeroCodeAutomationRun, METHOD.POST, param, {
    timeout: 9999999999999,
  });
}

/**
 *
 */
export function workflowEngineRevokeByCreateUser(param) {
  return request(WorkflowEngineRevokeByCreateUser, METHOD.POST, param);
}

/**
 *
 */
export function reportData(param) {
  return excelDownload(SystemWorkSheetReport, param, param.reportName);
}

/**
 *
 */
export function reportDataTemplate(param) {
  return excelDownload(
    SystemZeroCodeDataReportTemplate,
    param,
    param.reportName
  );
}

/**
 *
 */
export function importData(param) {
  return request(SystemZeroCodeDataImport, METHOD.POST, param, {
    timeout: 9999999999999,
    headers: {
      "Content-Type": "multipart/form-data;boundary=" + new Date().getTime(),
    },
  });
}
/**
 *
 */
export function importDataTable(param) {
  return request(SystemZeroCodeDataImportTable, METHOD.POST, param, {
    timeout: 9999999999999,
    headers: {
      "Content-Type": "multipart/form-data;boundary=" + new Date().getTime(),
    },
  });
}
/**
 *
 */
export function importTemplate(param) {
  return excelDownload(
    SystemZeroCodeDataImportTemplate,
    param,
    param.reportName
  );
}

/**
 * 根据Id获取
 */
export async function menuZeroCode(param) {
  return request(SystemUserMenuZeroCode, METHOD.POST, param);
}

/**
 * 根据Id获取
 */
export function findZeroCodeById(id) {
  return request(SystemZeroCodeFindById + "/" + id, METHOD.GET, {});
}

/**
 * 查询
 */
export function queryTable(form) {
  return request(
    SystemZeroCodeDataFindFormSourcePagingTable,
    METHOD.POST,
    form
  );
}

/**
 * 复制
 */
export function copy(param) {
  return request(SystemWorkSheetCopy, METHOD.POST, param);
}

/**
 *
 */
export async function gridCustomFindByKey(id) {
  return request(SystemZeroCodeGridCustomFindByKey + "/" + id, METHOD.GET, {});
}

/**
 */
export async function gridCustomSave(param) {
  return request(SystemZeroCodeGridCustomSave, METHOD.POST, param);
}
export default {
  query,
  queryTable,
  queryFooter,
  queryConfig,
  queryCorrelation,
  del,
  delPhysics,
  delPhysicsAll,
  delRecovery,
  eventApi,
  reportData,
  reportDataTemplate,
  importData,
  importDataTable,
  importTemplate,
  workflowEngineRevokeByCreateUser,
  menuZeroCode,
  findZeroCodeById,
  automationRun,
  findById,
  queryFilterSearch,
  copy,
  gridCustomFindByKey,
  gridCustomSave,
};
